package main

import (
	"fmt"
	"net"
	"time"
)

func main() {
	listener, err := net.Listen("tcp", "127.0.0.1:9999")
	if err != nil {
		fmt.Println(err)
		return
	}

	for {
		conn, err := listener.Accept()
		if err != nil {
			fmt.Println(err)
			continue
		}
		fmt.Println("客户端连接成功：", conn.RemoteAddr())
		go func() {

			time.Sleep(time.Second * 10)
			fmt.Fprintln(conn, time.Now().Format("2006-01-02 15:04:05"))
			conn.Close()
		}()

	}
	listener.Close()
}
